package com.zjeav.lingjiao.ui.book;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zjeav.lingjiao.R;
import com.zjeav.lingjiao.base.baseBean.Order;

public class OrderAdapter extends BaseQuickAdapter<Order, BaseViewHolder> {
    private Context context;

    public OrderAdapter(Context context) {
        super(R.layout.order_item);
        this.context = context;
    }


    @Override
    protected void convert(com.chad.library.adapter.base.BaseViewHolder helper, Order item) {
        helper.setText(R.id.book_info_txt, item.getBooks().get(0).getName());
        helper.setText(R.id.book_amount_txt, "￥"+item.getBooks().get(0).getAmount());
        if (item.getPaied()) {
            helper.setText(R.id.book_pay_amount_txt, "实付款:￥" + item.getAmount());
        } else {
            helper.setText(R.id.pay_time_txt,"下单时间:"+item.getOrdertime());
            helper.getView(R.id.pay_txt).setVisibility(View.VISIBLE);
            helper.getView(R.id.pay_time_txt).setVisibility(View.VISIBLE);
            if (item.getCancel()){
                helper.setText(R.id.pay_txt, "去付款");
                helper.addOnClickListener(R.id.pay_txt);
                helper.setVisible(R.id.pay_txt,false);
            }else {
                helper.setText(R.id.pay_txt, "去付款");
                helper.addOnClickListener(R.id.pay_txt);
            }

        }


        ImageView imageView = helper.getView(R.id.book_cover_img);
        Glide.with(context)
                .load(item.getBooks().get(0).getCover())
                .error(R.mipmap.user_uesrinfo)
                .into(imageView);


    }
}